<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'sys_user_list.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="shortcut icon" href="${ctx }/ico/favicon.ico">
<link href="${ctx }/css/bootstrap.min.css" rel="stylesheet">
<link href="${ctx }/css/font-awesome.css" rel="stylesheet">
 <link href="${ctx }/css/common.css" rel="stylesheet">
<link href="${ctx }/css/plugins/multiselect/bootstrap-multiselect.css"
	rel="stylesheet">
<!-- jqgrid-->
<link href="${ctx }/css/plugins/jqgrid/ui.jqgrid.css?0820"
	rel="stylesheet">
<link href="${ctx }/css/plugins/jsTree/style.min.css" rel="stylesheet">
<link href="${ctx }/css/animate.css" rel="stylesheet">
<link href="${ctx }/css/style.css" rel="stylesheet">
<!-- Sweet Alert -->
<link href="${ctx }/css/plugins/sweetalert/sweetalert.css"
	rel="stylesheet">
<!-- zTree -->
<link href="${ctx }/css/plugins/zTreeStyle/metro.css" rel="stylesheet">
<!--bootstrap-select-->
<link
	href="${ctx}/css/plugins/bootstrap-select/bootstrap-select.min.css"
	rel="stylesheet" />
	<style>
	   
	    #xz #treeDemo{
	    	border:1px solid black;
	    	margin-top:0;width:100%;height:200px;position:absolute;background:#fff;overflow:auto;z-index:100;
	    }
	</style>
</head>
<body class="gray-bg">
	<div class="animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox">
					<div class="ibox-content">
						<div class="row m-b-sm m-t-sm">
							<div class="col-md-11">
								<div class="input-group">
									<button class="btn btn-success btn-outline commonbtn" type="button"
										id="addSysUser">
										<i class="fa fa-plus"></i> 添加
									</button>
									<button class="btn btn-success btn-outline commonbtn" type="button"
										id="editSysUser">
										<i class="fa fa-pencil"></i> 编辑
									</button>
									<button class="btn btn-success btn-outline commonbtn" type="button"
										id="delSysUser">
										<i class="fa fa-trash"></i> 删除
									</button>
									<input type="text" placeholder="请输入系统账户"
										class="input-sm form-control"
										style="float: right;height:100%;width:50%" id="search">
									<span class="input-group-btn"><button type="button"
											class="btn btn-sm btn-sm btn-primary commonsearch" id="searchBtn">搜索</button>
									</span>
								</div>
							</div>
						</div>
						<div class="jqGrid_wrapper">
							<table id="table_list"></table>
							<div id="pager_list"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


	<!-- 添加用户模块窗口 -->
	<div class="modal inmodal" id="addSysUserWin" role="dialog"
		aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content animated bounceInRight">
				<div class="modal-header">
					<button type="button" class="close closeWin" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
					</button>
					<h4 class="modal-title">添加用户</h4>
				</div>
				<div class="ibox-content">
					<form class="form-horizontal m-t" id="addSysUserFrom">
						<div class="form-group">
							<label class="col-sm-3 control-label">员工编号:</label>
							<div class="col-sm-8">
								<input id="emp_id" name="emp_id" class="form-control"
									required="" aria-required="ture" type="text"
									placeholder="请输入员工编号">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">成员姓名:</label>
							<div class="col-sm-8">
								<input id="emp_name" name="emp_name" class="form-control"
									required="" aria-required="ture" disabled="disabled"
									type="text" placeholder="">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">所在部门:</label>
							<div class="col-sm-8">
								<input id="orgName" name="orgName" class="form-control"
									required="" aria-required="true" disabled="disabled"
									type="text" placeholder="">
							</div>
						</div>
						<div class="form-group">
						<label class="col-sm-3 control-label">机构范围:</label>
						<div class="col-sm-6">
							<input id="org_id" name="org_id" type="hidden">
							 <input id="org_name" name="org_name" class="form-control" required=""
								aria-required="true" type="text" readOnly="true">
								<span class="help-block m-b-none" style="color: red; display:none;">请选择机构！</span>
								<div  id="xz"
							style="position: relative;left:0;">
							<input type="hidden" id="show_user" name="show_user">
							<ul id="treeDemo" class="ztree" ></ul>
						</div></div>
						<button type="button" class="btn btn-success btn-outline"
							id="SysUserOrg"
							onClick="getUserNode();">
							<i class="fa fa-plus"></i>请选择
						</button>
						
					</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">所属角色:</label>
							<div class="col-sm-8">
								<select class="selectpicker" required="" aria-required="true"
									name="roleId" id="roleId">
									<option value="">--请选择--</option>
									<c:forEach items="${roleList}" var="roleInfo">
										<option value="${roleInfo.id}">${roleInfo.name}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">系统账户:</label>
							<div class="col-sm-8">
								<input id="userName" name="userName" class="form-control"
									required="" aria-required="ture" type="text"
									placeholder="请输入系统账户">
							</div>

						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">系统密码:</label>
							<div class="col-sm-8">
								<input id="password" name="password" class="form-control"
									required="" aria-required="true" type="password"
									placeholder="请输入系统密码">

							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">账户说明:</label>
							<div class="col-sm-8">
								<input id="description" name="description" class="form-control"
									required="" aria-required="true" type="text"
									placeholder="请输入账户说明">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-8 col-sm-offset-5" style="height:60px">
								<button type="button" class="btn btn-white closeWin"
									data-dismiss="modal">关闭</button>
								<button type="submit" class="btn btn-primary">保存</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!--end 添加用户模块窗口 -->

	<!-- 修改用户模态窗口 -->
	<div class="modal inmodal" id="editSysUserWin" tabindex="-1"
		role="dialog" aria-hidden="true" style="padding-bottom:30px">
		<iframe id="editSysUserFrame" width="100%" height="100%"
			frameborder="0"> </iframe>
	</div>
	<!--end 修改用户模态窗口 -->
	<!-- 全局js -->
	<script src="${ctx }/js/jquery.min.js"></script>
	<script src="${ctx }/js/bootstrap.min.js"></script>
	<script src="${ctx }/js/plugins/multiselect/bootstrap-multiselect.js"></script>
	<!-- Peity -->
	<script src="${ctx }/js/plugins/peity/jquery.peity.min.js"></script>
	<!-- jqGrid -->
	<script src="${ctx }/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
	<script src="${ctx }/js/plugins/jqgrid/jquery.jqGrid.min.js"></script>
	<!-- jQuery Validation plugin javascript-->
	<script src="${ctx }/js/plugins/validate/jquery.validate.min.js"></script>
	<script src="${ctx }/js/plugins/validate/messages_zh.min.js"></script>
	<!-- layer javascript -->
	<script src="${ctx }/js/plugins/layer/layer.min.js"></script>
	<!-- jQuery form-->
	<script src="${ctx }/js/jquery.form.js"></script>
	<!-- 自定义js -->
	<script src="${ctx }/js/content.js"></script>
	<!-- jsTree plugin javascript -->
	<script src="${ctx }/js/plugins/jsTree/jstree.min.js"></script>
	<!-- Sweet alert -->
	<script src="${ctx }/js/plugins/sweetalert/sweetalert.min.js"></script>
	<!-- ztree plugin javascript -->
	<script src="${ctx }/js/plugins/zTree/jquery.ztree.core.min.js"></script>
	<script src="${ctx }/js/plugins/zTree/jquery.ztree.exhide.min.js"></script>
	<script src="${ctx }/js/plugins/zTree/jquery.ztree.exedit.min.js"></script>
	<script src="${ctx }/js/plugins/zTree/jquery.ztree.excheck.min.js"></script>
	<script
		src="${ctx}/js/plugins/bootstrap-select/bootstrap-select.min.js"></script>
	<script type="text/javascript">
		$('#example-multiple-selected').multiselect({
			buttonWidth : '100%'
		});
		$(document).ready(	function() {
		    orgTreeload();
			$.jgrid.defaults.styleUI = 'Bootstrap';
			$('#userName')
					.blur(
							function() {
								$('#userName').next().remove();
								var userName = $('#userName')
										.val();
								if (userName != null
										&& userName != '') {
									var userId = checkUserName(userName);
									if (userId != 0) {
										var spa = '<span class="help-block m-b-none" style="color: red;">用户名重复，请重新输入！</span>';
										$('#userName').after(
												spa);
										$('#userName').focus();
										return false;
									}
								}
							});

			$('#emp_id').blur(function() {
				$('#emp_id').next().remove();
				var emp_id = $('#emp_id').val();
				if (emp_id != null && emp_id != '') {
					checkEmpID(emp_id);

				}
			});

		$('#password').blur(function() {
				var reg = /^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{8,20}$/;
				var v_password = $('#password')
						.val();
				$('#password').next().remove();
				if (v_password.match(reg) == null) {
					var spa = '<span class="help-block m-b-none" style="color: red;">密码必须包含英文大写、小写和数字，长度为8-20位</span>';
					$('#password').after(spa);
					return false;
				}
				if (v_password.length < 8) {
					var spa = '<span class="help-block m-b-none" style="color: red;">密码不能小于8位</span>';
					$('#password').after(spa);
					return false;
				}
				var v_userName = $('#userName')
						.val();
				if (v_userName == v_password) {
					var spa = '<span class="help-block m-b-none" style="color: red;">账户和密码不能一致</span>';
					$('#password').after(spa);
					return false;
				}
			});
							//Examle data for jqGrid
		var searchString = '';
		//绑定表格数据
		$("#table_list")
				.jqGrid(
						{
							postData : {
								name : searchString
							},
							url : "${ctx}/security/user/loadDataGrid",
							datatype : "json",
							height : "calc(100% - 265px)",
							autowidth : true,
							shrinkToFit : true,
							multiselect : true,
							multiboxonly : true,
							beforeSelectRow : beforeSelectRow,
							rowList : [ 10, 20, 30 ],
							root : "rows",
							colNames : [ '用户ID', '系统账户',
									'姓名', '所在部门', '机构范围','所属角色',
									'状态', '是否在线', 
									'操作' ],
							colModel : [
									{
										name : 'id',
										index : 'id',
										width : 60,
										sorttype : "int"
									},
									{
										name : 'userName',
										index : 'userName',
										width : 100
									},
									{
										name : 'sysUserInfo.emp_name',
										index : 'sysUserInfo.emp_name',
										width : 60
									},
									{
										name : 'org_name',
										index : 'org_name',
										width : 80,
										formatter : function(
												cellvalue,
												options,
												rowObject) {
											var org_description = rowObject.sysOrgInfo;
											if (org_description == null
													|| org_description == "") {
												var spa = '<span style="color: red;">无</span>';
												return spa;
											} else {
												for ( var i = 0; i < rowObject.sysOrgInfo.length; i++) {
													return rowObject.sysOrgInfo[i].org_name;
												}
											}
										}
									},
									{
										name : 'org_name',
										index : 'org_name',
										width : 80,
										formatter : function(
												cellvalue,
												options,
												rowObject) {
											var v_sysUserPermission = rowObject.sysUserPermission;
											if (v_sysUserPermission == null
													|| v_sysUserPermission == "") {
												var spa = '<span style="color: red;">未指定</span>';
												return spa;
											} else {
												
													return rowObject.sysUserPermission.org_name;
												
											}
										}
									},
									{
										name : 'role_name',
										index : 'role_name',
										width : 100,
										sortable : false,
										formatter : function(
												cellvalue,
												options,
												rowObject) {
											var role_description = rowObject.roleList;
											if (role_description == null
													|| role_description == "") {
												var spa = '<span style="color: red;">未授权！</span>';
												return spa;
											} else {
												for ( var i = 0; i < rowObject.roleList.length; i++) {
													return rowObject.roleList[i].name;
												}
											}
										}
									},
									{
										name : 'state',
										index : 'state',
										width : 60,
										formatter : "select",
										editoptions : {
											value : "0:无效;1:正常;"
										}
									},
									{
										name : 'online',
										index : 'online',
										width : 60,
										formatter : function(
												cellvalue,
												options,
												rowObject) {
											var v_online = rowObject.online;
											if (v_online >= 1) {
												return "<i class=\"fa  fa-circle\" style=\"color: red;\"></i>";
											} else {
												return "<i class=\"fa  fa-circle\"></i>";
											}
										}
									},
									{
										name : 'oper',
										index : 'oper',
										width : 100,
										formatter : function(
												cellvalue,
												options,
												rowObject) {
											var v_result = '';
											var status = rowObject.state;
											var id = rowObject.id;
											var v_userName = rowObject.userName;
											var v_online = rowObject.online;
											if (status == 1) {
												v_result += "<button class=\"btn btn-success btn-outline\" type=\"button\" style=\"margin-right:10px;\" onClick=\"disableSysUser("
														+ id
														+ ","
														+ status
														+ ");\"><i class=\"fa fa-expeditedssl\"></i> 禁用</button>";
											}
											if (status == 0) {
												v_result += "<button class=\"btn btn-success btn-outline\" type=\"button\"  onClick=\"disableSysUser("
														+ id
														+ ","
														+ status
														+ ");\"><i class=\"fa fa-unlock\"></i> 启用</button>";
											}
											if (v_online >= 1) {
												v_result += "<button class=\"btn btn-success btn-outline\" type=\"button\"  onClick=\"offline('"
														+ v_userName
														+ "');\"><i class=\"fa fa-expeditedssl\"></i> 下线</button>";
											}
											return v_result;
										}
									} ],
							sortable : true,
							sortname : 'id',
							sortorder : 'asc',
							pager : "#pager_list",
							caption : "系统用户列表",
							viewrecords : true,
						});

			/**
			 * 验证userName是否存在
			 * 返回userName对应用户true/flase
			 */
			function checkUserName() {
				$('#userName').next().remove();
				var userName = $('#userName').val();
				var flag = 0;//不存在
				$.ajax({
					async : false,
					type : "post",
					url : "${ctx }/security/user/checkSysUser",
					data : "userName=" + userName,
					success : function(data) {//fuction(data)，data:isExistSysUser的返回值
						if (data == true) {

							return false;
						} else {
							flag = 1;
						}
					},
					error : function() {
						//layer.alert('连接失败！',{icon: 2});
					}
				});
				return flag;//不存在相同的返回true,存在相同的返回false
			}

		/**
		 * 验证emp_id是否存在
		 * 返回emp_id对应用户true/flase
		 */
		function checkEmpID() {
			$('#emp_id').next().remove();
			var emp_id = $('#emp_id').val();
			var flag = 0;//不存在
			$
					.ajax({
						async : false,
						type : "post",
						url : "${ctx }/security/user/checkEmpid",
						data : {
							"emp_id" : emp_id
						},
						success : function(data) {//fuction(data)，data:isExistSysUser的返回值		    		
							if (data.result == "0") {
								//绑定姓名
								$("#emp_name").val(data.sysUserInfo.emp_name);
								//遍历部门
								var org_name = "";
								$.each(data.sysUserInfo.sysOrgInfoList,
								function(i,item) 
								{
								 org_name += item.org_name+ ",";
								});
								//删除部门最后一个分隔符
								if (org_name.length > 0) {
									org_name = org_name
											.substr(
													0,
													org_name.length - 1);
								}
								$("#orgName").val(org_name);
										
								/*
								$("#userName").val(data.currentUser.userName);
								$("#password").val(data.currentUser.password); */
							} else if (data.result == "1") {
								var spa = '<span class="help-block m-b-none" style="color: red;">当前员工已经开户!</span>';
								$('#emp_id').after(spa);
								$('#emp_id').focus();
								$("#emp_name").val("");
								$("#description").val("");
								$("#userName").val("");
								$("#password").val("");
								$("#orgName").val("");
								return false;
							} else {
								var spa = '<span class="help-block m-b-none" style="color: red;">当前员工不存在!</span>';
								$('#emp_id').after(spa);
								$('#emp_id').focus();
								$("#emp_name").val("");
								$("#description").val("");
								$("#userName").val("");
								$("#password").val("");
								$("#orgName").val("");
								return false;
							}
						},
						error : function() {
							//layer.alert('连接失败！',{icon: 2});
						}
					});
			return flag;//不存在相同的返回true,存在相同的返回false
		}

				 //绑定add表单提交事件,异步提交表单
        $("#addSysUserFrom").submit(function(){
        	$.ajax({
		    	type: "post",
		    	url: "${ctx }/security/user/doAddSysUser",
		    	dataType:"json",
		     	data: $('#addSysUserFrom').serialize(),
		     	success: function(data) {
		      		if(data.errcode=="0")
		      		{
		      			layer.alert(data.errmsg,{icon: 1}, function(index){		      			
		      				//刷新表格数据
							$("#table_list").trigger("reloadGrid");	
							//清空表单数据
							$("#addSysUserFrom :input").not(":button, :submit, :reset").val("").removeAttr("checked").remove("selected");
					    	//清除上次选择的人员或机构
					    	var nodes = treeUser.getCheckedNodes(true);
							for(obj in nodes){
								var node = nodes[obj];
								node.checked = false;
								treeUser.updateNode(node);
							}
							$("#roleId").selectpicker("refresh");
							
							//刷新表格数据
							addWinClose('0');
							//关闭提示框
							layer.close(index);
						});
		      		}else
		      		{
		      			layer.alert(data.errmsg,{icon: 2});
		      		}
		      	},
		      	error: function() {		      		
		      		layer.alert('添加用户失败！',{icon: 2});
        		}
        	});
        	return false;
        	
        });
	});
        

		// jqGrid 自动调整宽度
		$(window).bind('resize', function() {
			var width = $('.jqGrid_wrapper').width();
			$('#table_list').setGridWidth(width);
		});

		function beforeSelectRow() {
			$("#jqgridId").jqGrid('resetSelection');
			return (true);
		}

		//绑定查询事件
		$("#searchBtn").click(function() {
			var searchString = $("#search").val();
			$("#table_list").jqGrid('setGridParam', {
				url : "${ctx }/security/user/loadDataGrid",
				postData : {
					'userName' : searchString
				}, //发送数据 
				page : 1
			}).trigger("reloadGrid"); //重新载入 
		});

		//关闭控制
		$('.closeWin').click(function() {
			addWinClose('1');
		});
		//关闭新增按钮事件
		function addWinClose(flag) {
			if (flag == "0") {
				$("#table_list").trigger("reloadGrid");
			}
			$('#addSysUserWin').modal('hide');

		}
		//绑定修改按钮事件
		$("#editSysUser").click(
				function() {
					var selectedId = $("#table_list").jqGrid("getGridParam",
							"selrow");
					if (selectedId == null || selectedId == "") {
						layer.alert('请选择一项！', {
							icon : 0
						});
						return;
					}
					var frameSrc = "${ctx }/security/user/editSysUser?userId="
							+ selectedId;
					$("#editSysUserFrame").attr("src", frameSrc);
					$('#editSysUserWin').modal('show');
				});
		//关闭修改按钮事件
		function editWinClose(flag) {
			if (flag == "0") {
				$("#table_list").trigger("reloadGrid");
			}
			//关闭add窗口
			$("#editSysUserFrame")[0].contentWindow.document.write('');
			$("#editSysUserFrame")[0].contentWindow.close();
			$('#editSysUserWin').modal('hide');
		}

		//绑定分配权限窗口事件
		function SysUserRole(id) {
			var frameSrc = "${ctx }/security/user/editUserRole?user_id=" + id;
			$("#SysUserRoleFrame").attr("src", frameSrc);
			$('#SysUserRoleWin').modal('show');
		};

		//关闭分配权限窗口事件
		function sysUserRoleClose(flag) {
			if (flag == "0") {
				$("#table_list").trigger("reloadGrid");
			}

			//关闭add窗口
			$('#SysUserRoleWin').modal('hide');
		}

		//绑定新增按钮事件
		$("#addSysUser").click(function() {
			//显示添加用户信息页面
			$('#addSysUserWin').modal('show');
			$('#example-multiple-selected').multiselect();
		});

		//禁用与启用
		function disableSysUser(x, y) {
		   if(y==0){
		     y=1;
		   }else{
		     y=0;
		   }
			$.ajax({
				type : "post",
				url : "${ctx }/security/user/disableSysUser",
				data : {
					"id" : x,
					"state" : y,
				},
				dataType : "json",
				success : function(data) {
					if (data.errcode == "0") {
						layer.alert(data.errmsg, {
							icon : 1
						}, function(index) {
							//刷新表格数据
							$("#table_list").trigger("reloadGrid");
							//关闭提示框
							layer.close(index);
						});
					} else {
						layer.alert(data.errmsg, {
							icon : 2
						});
					}
				},
				error : function() {
					layer.alert('操作失败！', {
						icon : 2
					});
				}
			});
		}
		//下线
		function offline(x) {
			$.ajax({
				type : "post",
				url : "${ctx }/offline",
				data : {
					"name" : x
				},
				dataType : "json",
				success : function(data) {
					if (data.errcode == "1") {
						layer.alert(data.errmsg, {
							icon : 1
						}, function(index) {
							//刷新表格数据
							$("#table_list").trigger("reloadGrid");
							//关闭提示框
							layer.close(index);
						});
					} else {
						layer.alert(data.errmsg, {
							icon : 2
						});
					}
				},
				error : function() {
					layer.alert('操作失败！', {
						icon : 2
					});
				}
			});
		}

		//绑定删除事件
		$("#delSysUser").click(
				function() {

					var selectedIds = $("#table_list").jqGrid("getGridParam",
							"selarrrow");
					if (selectedIds == "") {
						layer.alert('请选择一项！', {
							icon : 0
						});
						return;
					}

					swal({
						title : "您确定要删除这条信息吗",
						text : "删除后将无法恢复，请谨慎操作！",
						type : "warning",
						showCancelButton : true,
						confirmButtonColor : "#DD6B55",
						confirmButtonText : "删除",
						closeOnConfirm : false
					}, function() {
						$.ajax({
							type : "post",
							dataType : "json",
							url : "${ctx }/security/user/deleteSysUser",
							data : "ids=" + selectedIds,
							success : function(data) {
								if (data.errcode == 0) {
									//刷新表格数据
									$("#table_list").trigger("reloadGrid");
									swal("删除成功！", "您已经永久删除了这条信息。", "success");
								} else {
									swal("删除用户失败！", "您未删除这条信息。", "error");
								}
							},
							error : function() {
								swal("删除用户失败！", "您未删除这条信息。", "error");
							}
						});
					});
				});
				
				//-------选择机构树加载 START--------//
	var treeUser;
	var v_node_id;
	var setting = {
		check : {
			enable : true,
			chkStyle : "radio",
			radioType : "all"
		},
		data : {
			simpleData : {
				enable : true,
				idKey : "id",
				pIdKey : "pId"
			}
		},
		async : {
			enable : true,
			url : "${ctx}/orgTree/getOrgJson",
			autoParam : [ "id", "name" ]
		},
		callback : {
			onCheck : zTreeOnCheck,
			onExpand : zTreeOnExpand
		}
	};
	//初始化加载选择机构树
	function orgTreeload() {
		$('#xz').hide();
		$.fn.zTree.init($("#treeDemo"), setting);
		treeUser = $.fn.zTree.getZTreeObj("treeDemo");
	}
	//节点展开触发
	function zTreeOnExpand(event, treeId, treeNode) {
		//alert(treeNode.id + ", " + treeNode.name+"--"+v_node_id);
		var v_child_node = treeNode.children;
		for ( var j = 0; j < v_child_node.length; j++) {
			//alert("v_child_node-"+v_child_node[j].id+","+v_node_id);
			if (v_child_node[j].id == v_node_id) {
				treeUser.checkNode(v_child_node[j], true);
			}
		}
	};
	//选择节点触发
	function zTreeOnCheck(event, treeId, treeNode) {
		var nodes = treeUser.getCheckedNodes(true);
		if(nodes.length>0){
			$('#org_id').val(treeNode.id);
			$('#org_name').val(treeNode.name);
		}
		else{
			$('#org_id').val("");
			$('#org_name').val("");
		}
		
		$("#show_user").val("");
		$('#xz').hide();
	};
  //点击请选择，选择用户-层显示控制
	function sysuser() {
		var v_show_user = $("#show_user").val();
		if (v_show_user == "") {
			$("#show_user").val("0");
		    $('#orgs_name').next().hide();
			$('#xz').show();
		} else {
			$('#xz').hide();
			$("#show_user").val("");
		}
	}
	//点击按钮触发-选择用户操作
	function getUserNode(x) {
		sysuser();
		v_node_id = x;
	}
	
	//------------end--------------------//
	</script>
</body>
</html>
